package system

type Runner struct {
	Data interface{}
	Fn func(data interface{})
}

var size = 1
var RunnerChan chan Runner

func init()  {
	RunnerChan = make(chan Runner, 1000)
	for k := 0; k < size; k++ {
		go consumer(RunnerChan)
	}
}

// 消费任务
func consumer(ch <-chan Runner)  {
	for {
		select {
		case c := <-ch:
			go c.Fn(c.Data)
		default:

		}
	}
}

// 生产任务
func Producter(data interface{}, fn func(data interface{}))  {
	RunnerChan <- Runner{Data:data, Fn:fn}
}









//type fn func(data chan interface{}) error
//
//type runner struct {
//	data chan interface{}
//	Producter  fn
//	Consumer   fn
//}
//
//func NewRunner(size int)  {
//	for k := 0; k < size; k++ {
//
//	}
//}



